#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point()
    : _ix(0)
    , _iy(0)
    {
        cout << "Point()" << endl;
    }

    Point(int x,int y = 1)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        /* cout << "拷贝构造" << endl; */
    }

    Point & operator=(const Point & rhs){
        /* cout << "赋值运算符函数" << endl; */
        _ix = rhs._ix;
        _iy = rhs._iy;
        return *this;
    }

    //在const成员函数中不能修改数据成员
    //const Point * const this;
    void print() const{
        cout << "const版本print" << endl;
        /* _ix = 100; */
        cout << "(" << this->_ix
            << "," << this->_iy
            << ")" << endl;
    }

    //Point * const this
    /* void print(){ */
    /*     cout << "非const版本print" << endl; */
    /*     /1* _ix = 100; *1/ */
    /*     cout << "(" << this->_ix */
    /*         << "," << this->_iy */
    /*         << ")" << endl; */
    /* } */

    void setX(int x){
        _ix = x;
    }
private:
    int _ix;
    int _iy;
};

void test0(){
    Point pt(5,6);
    pt.setX(10);
    pt.print();

    //const对象一经初始化就不能修改对象的数据成员
    const Point pt2(3,5);
    /* pt2.setX(18); */
    pt2.print();

}

int main(void){
    test0();
    return 0;
}
